package com.ruoyi.web.controller.majors;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.Major;
import com.ruoyi.system.service.impl.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/majors/majors")
public class MajorsController extends BaseController {

    @Autowired
    private MajorService majorService;
    //搜索查询功能
    @PostMapping("/select")
    public List<Major> selectMajor(@RequestBody Major major) {
        List<Major> majors = majorService.selectMajorList(major);
        return majors;
    }

    //添加专业功能
    @PostMapping("/insert")
    public String insertMajor(@RequestBody Major major) {
        String str = majorService.insertMajor(major);
        return str;
    }

    //批量删除专业功能
    @PostMapping("/delete")
    public String deleteMajor(@RequestBody List<Major> majors) {
        String str = majorService.deleteMajor(majors);
        return str;
    }

    //修改专业功能,根据id进行修改
    @PostMapping("/update")
    public String updateMajor(@RequestBody Major major) {
        String str = majorService.updateMajor(major);
        return str;
    }

    /**
     * 获取岗位列表
     */
//    @PreAuthorize("@ss.hasPermi('system:post:list')")
    @GetMapping("/list")
    public TableDataInfo list(Major major)
    {
        startPage();
        List<Major> list = majorService.selectPostList(major);
        return getDataTable(list);
    }


    @DeleteMapping("/{postIds}")
    public AjaxResult remove(@PathVariable Long[] postIds)
    {
        return toAjax(majorService.deletePostByIds(postIds));
    }

}
